home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
gausselm
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
9KB
Path: seq!spell
From: Robert Brunner <brunner@uirvld.csl.uiuc.edu>
Subject: v02i018: gausselm - Gaussian elimination and QR factorization v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu
Checksum: 925599671 (verify with brik -cv)
Submitted-by: Robert Brunner <brunner@uirvld.csl.uiuc.edu>
Posting-number: Volume 2, Issue 18
Archive-name: gausselm/part01
BEGIN_DOC gausselm.doc
Gaussian elimination and QR factorization
Robert Brunner
brunner@uirvld.csl.uiuc.edu
The following directory contains two useful linear algebra routines and
three subroutine functions.
QR: QR decomposes a matrix on the stack, A, into an orthogonal
matrix Q and a upper triangular matrix R such that A=QR, using
Gram-Schmidt orthogonalization. The program only works for full-rank
matricies.
LU: LU decomposes the matrix from the stack, A, into a permutation
matrix P, a lower triangular matrix L, and an upper triangular matrix
U, such that PA=LU. Pivoting is only performed when necessary, and
the first non-zero pivot is selected, rather than always choosing the
largest pivot. By doing this, pivoting is avoided when not needed,
which is useful for solving small problems given for homework in linear
algebra classes. The method does exhibit poor numerical stability,
so the program is not practical for large matrices.
DCMP: DCMP decomposes a matrix [[row 1][row 2]...[row n]] into a
list of vectors {[row 1][row 2]...[row n]}. Doing this speeds up
the other two routines.
RCMP: RCMP reverses DCMP.
SWRW: SWRW switches the two specified rows of a matrix decomposed
by DCMP.
'GAUSSELM' BYTES gives checksum #33398d, 1458 bytes
Drop me a line if you find this useful.
brunner@uirvld.csl.uiuc.edu
END_DOC
BEGIN_RPL gausselm.rpl
%%HP: T(3)A(R)F(.);
DIR
QR
\<< TRN CONJ DCMP
OVER DUP 2 \->LIST 0
CON { } \-> a n m r q
\<< a 1 GET DUP
DUP ABS / DUP ROT
DOT 'r' { 1 1 } ROT
PUT 'q' SWAP STO+ 2
n
FOR i a i
GET DUP \-> ai
\<< 1 i 1 -
FOR j
DUP q j GET DUP ai
DOT 'r' { j i } ROT
PUT DUP ROT DOT * -
NEXT
DUP ABS / DUP ai
DOT 'r' { i i } ROT
PUT 'q' SWAP STO+
\>>
NEXT q RCMP
TRN CONJ r
\>>
\>>
LU
\<< DCMP OVER IDN
DUP 0 CON DCMP
DROP2 SWAP DCMP
DROP2 1 DUP DUP
RCLF \-> a m n l p pr
pc sr flg
\<<
WHILE pr m
< pc n \<= AND
REPEAT 1 CF
WHILE 1
FC? pc n \<= AND
REPEAT pr
'sr' STO
WHILE 1
FC? sr m \<= AND
REPEAT
IF a
sr GET pc GET
THEN
1 SF
ELSE
'sr' INCR DROP
END
END
IF 1
FC?
THEN
'pc' INCR DROP
END
END
IF 1 FS?
THEN
IF pr
sr \=/
THEN
'p' pr sr SWRW 'l'
pr sr SWRW 'a' pr
sr SWRW
END a
pr GET DUP pc GET \->
pivr piv
\<< pr 1
+ m
FOR i
a i GET DUP pc GET
piv / DUP l i GET
pr ROT PUT 'l' i
ROT PUT pivr * -
'a' i ROT PUT
NEXT
\>>
END 'pr'
INCR 'pc' INCR
DROP2
END p RCMP
l RCMP m IDN + a
RCMP flg STOF
\>>
\>>
DCMP
\<< OBJ\-> OBJ\->
DROP DUP2 * OVER 1
- \-> m n mn n1
\<< 1 m
FOR i n
\->ARRY mn n1 i * -
ROLLD
NEXT m
\->LIST m n
\>>
\>>
RCMP
\<< OBJ\-> OVER
SIZE OBJ\-> DROP OVER
\-> m n st
\<< 1 m
START OBJ\->
DROP 'st' n 1 -
STO+ st ROLL
NEXT 1 n 1
-
START st
ROLL
NEXT { m n
} \->ARRY
\>>
\>>
SWRW
\<< \-> i j
\<< DUP i GET
SWAP DUP DUP j GET
i SWAP PUT j ROT
PUT
\>>
\>>
END
END_RPL
BEGIN_ASC gausselm.asc
%%HP: T(3)A(D)F(.);
"69A20FF7C780000000403575257540D9D20E16321C432D6E201096D6E2010A6E
163278BF1D6E2010966C7D1DBBF178BF178BF1D6E2010A66C7D1D6E201096DBB
F1704D1D6E2010A6E0CF1704D1EF53293632B213079000402534D40540D9D20E
1632B7FC192CF18B9C1B7FC18DBF192CF11C432D6E2010D6D6E2010E6D6E2020
3747E16329C2A2D6E2010D630132B7FC18DBF145632D6E2020374797632D6E20
10E69C2A290DA1B4402D6E202037475BCF1C42329C2A2D6E2010E69C2A290DA1
30132D6E202037475BCF1C423247A20D6E2010D6D6E2010E6B2130900D1EF532
93632B2130C1100404434D40540D9D20E1632B7FC1B7FC18DBF12ABF1EEDA192
CF19C2A290DA11C432D6E2010D6D6E2010E6D6E2020D6E6D6E2020E613E16329
C2A2D6E2010D60A132D6E201096D6E2010E6900D1D6E2020D6E6D6E2020E613D
6E201096EEDA190DA10DCF1C4232D6E2010D6387C1D6E2010D6D6E2010E6EF53
293632B2130CF00020C45520D9D20E163284E20404434D40592CF1CD2D178BF1
4B2A2681D184E20404434D4053FBF1DBBF184E20404434D4053FBF19C2A278BF
178BF1916C11C432D6E201016D6E2010D6D6E2010E6D6E2010C6D6E201007D6E
20200727D6E20200736D6E20203727D6E203066C676E163233032D6E20200727
D6E2010D6EBBE1D6E20200736D6E2010E6CFCE1387E1D5032D9D209C2A25D2C1
330329C2A2063C1D6E20200736D6E2010E6CFCE1387E1D5032D9D20D6E202007
2745632D6E2020372797632DCC02330329C2A2063C1D6E20203727D6E2010D6C
FCE1387E1D5032D9D203CE22D6E201016D6E202037276C7D1D6E202007366C7D
1AFE22D9D209C2A2472C1B21305BF22D9D2045632D6E20203727976324F8028D
BF1B21305DF22B2130496323CE229C2A2063C1AFE22D9D2045632D6E20200736
976324F8028DBF1B21305DF22B2130496323CE229C2A2313C1AFE22D9D203CE2
2D6E20200727D6E20203727D9AE1AFE22D9D2045632D6E20100797632D6E2020
0727D6E2020372784E20403575257545632D6E2010C697632D6E20200727D6E2
020372784E20403575257545632D6E20101697632D6E20200727D6E202037278
4E204035752575B21305DF22D6E201016D6E202007276C7D178BF1D6E2020073
66C7D11C432D6E204007966727D6E2030079667E1632D6E202007279C2A276BA
1D6E2010D60A132D6E201096D6E201016D6E2010966C7D178BF1D6E202007366
C7D1D6E203007966750FA178BF1D6E2010C6D6E2010966C7D1D6E20200727E0C
F1704D145632D6E2010C697632D6E201096E0CF1704D1D6E204007966727EEDA
190DA145632D6E20101697632D6E201096E0CF1704D1C4232EF532B21305DF22
45632D6E20200727976324F80245632D6E20200736976324F8023FBF1B213049
632D6E20100784E20402534D405D6E2010C684E20402534D405D6E2010D6CD2D
176BA1D6E20101684E20402534D405D6E203066C676F76C1EF53293632B2130F
A50020152520D9D20E1632293D1E6AA184E20404434D40592CF178BF1ED2A238
7C14B2A2681D147A20B21301C432D6E201016D6E2010E6D6E2010D6D6E201027
D6E201017E1632D6E2010169C2A26C7D178BF178BF1F1AA150FA178BF1E0CF1E
FFB145632D6E2010279763247A209C2A29C2A2B2130E0CF1704D145632D6E201
01797632DBBF1B4402ED2A2D6E2010E60A132D6E201096D6E201016D6E201096
6C7D178BF11C432D6E20201696E16329C2A2D6E2010969C2A290DA10A132D6E2
010A678BF1D6E201017D6E2010A66C7D178BF1D6E20201696EFFB145632D6E20
10279763247A20D6E2010A6D6E201096B2130E0CF1704D178BF1E0CF1EFFB1EE
DA190DA1C423278BF1F1AA150FA178BF1D6E20201696EFFB145632D6E2010279
763247A20D6E201096D6E201096B2130E0CF1704D145632D6E20101797632DBB
F1B4402EF532C4232D6E20101784E20402534D405293D1E6AA1D6E201027EF53
293632B21306728"
END_ASC
BYTES: #8276h 1462
BEGIN_UU gausselm.uue
begin 644 gausselm
M2%!(4#0X+466*O!_?`@````$4U=25P2=+>!A(\$TTN8"`6EM+A"@YF$CA_O11
MY@(!:<;7T;L?A_MQN!]M+A"@9GP=;2X0D-:['P?4T>8"`6H._'%`'?XUDF,C*
M*S%P"0`$4D--4`2=+>!A(WO/D<(?N,FQ]QS8^Y'"'\$TTN8"`6UM+A#@UN8"1
M`G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